#region " using "
using System;
using System.Data;
using System.Web.UI.WebControls;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Threading;
using System.Globalization;
using System.Text;
using System.IO;
using Smarty;
using Data;
#endregion

public partial class Ccategorydetail_Search : AspNetRunnerPage
{
    int mypage = 1;
    int id = 1;
    string key;
    string templatefile = string.Empty;

    protected void Page_Init( object sender,  System.EventArgs e)  
    {
        strTableName = "categorydetail";
        strTableNameLocale = "categorydetail";
    }

    protected void Page_Load(object sender, EventArgs e)
    {
            // mandatory entry so compiler knows what table is processing
                        CheckSecurity();
            BuildForm();
            BuildBody();
            output.Append(func.BuildOutput(this, @"~\admin\categorydetail_search.aspx", smarty));

            this.Response.Write(output.ToString());
            this.Response.End();
    }

    private string GetIncludes()
    {
        StringBuilder includes = new StringBuilder();
		includes.Append("<script language=\"JavaScript\" src=\"include/calendar.js\"></script>\r\n");
        includes.Append("<script language=\"JavaScript\" src=\"include/jsfunctions.js\"></script>\r\n");
        includes.Append("<script language=\"JavaScript\" src=\"include/jquery.js\"></script>\r\n");
        if (useAJAX) 
        {
            includes.Append("<script language=\"JavaScript\" src=\"include/onthefly.js\"></script>\r\n");
            includes.Append("<script language=\"JavaScript\" src=\"include/ajaxsuggest.js\"></script>\r\n");
        }
        includes.Append("<script language=\"JavaScript\" type=\"text/javascript\">\r\n");
        includes.Append("var locale_dateformat = '" + Control.locale_info("LOCALE_IDATE", smarty) + "';\r\n");
        includes.Append("var locale_datedelimiter = \"" + Control.locale_info("LOCALE_SDATE", smarty) + "\";\r\n");
        includes.Append("var bLoading=false;\r\n");
        includes.Append("var TEXT_PLEASE_SELECT='" + Control.AddSlashes("Please select") + "';\r\n");
        if (useAJAX) 
        {
            includes.Append("var SUGGEST_TABLE = \"categorydetail_searchsuggest.aspx\";\r\n");
        }
	    includes.Append("var detect = navigator.userAgent.toLowerCase();");
        includes.Append("function checkIt(string)");
        includes.Append("{");
	    includes.Append("place = detect.indexOf(string) + 1;");
	    includes.Append("thestring = string;");
	    includes.Append("return place;");
        includes.Append("}");
        includes.Append("function ShowHideControls()");
        includes.Append("{");
	    includes.Append("document.getElementById('second_CateDetailID').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_CateDetailID'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("document.getElementById('second_Name').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_Name'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("document.getElementById('second_CateID').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_CateID'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("document.getElementById('second_Description').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_Description'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("document.getElementById('second_VipLevel').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_VipLevel'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("document.getElementById('second_Active').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_Active'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("document.getElementById('second_Image').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_Image'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("document.getElementById('second_Price').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_Price'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("document.getElementById('second_Status').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_Status'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("document.getElementById('second_Quantity').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_Quantity'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("document.getElementById('second_QuantitySold').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_QuantitySold'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("document.getElementById('second_CreatedDate').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_CreatedDate'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("document.getElementById('second_UpdatedDate').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_UpdatedDate'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("document.getElementById('second_Hot').style.display =  ");
		includes.Append("document.forms.editform.elements['asearchopt_Hot'].value==\"Between\" ? '' : 'none'; ");
	    includes.Append("return false;");
        includes.Append("}");
        includes.Append("function ResetControls()");
        includes.Append("{");
	    includes.Append("var i;");
	    includes.Append("e = document.forms[0].elements; ");
	    includes.Append("for (i=0;i<e.length;i++)"); 
	    includes.Append("{");
		includes.Append("if (e[i].name!='type' && e[i].className!='button' && e[i].type!='hidden')");
		includes.Append("{");
		includes.Append("if(e[i].type=='select-one')");
		includes.Append("e[i].selectedIndex=0;");
	    includes.Append("else if(e[i].type=='select-multiple')");
		includes.Append("{");
		includes.Append("var j;");
		includes.Append("for(j=0;j<e[i].options.length;j++)");
		includes.Append("e[i].options[j].selected=false;");
		includes.Append("}");
		includes.Append("else if(e[i].type=='checkbox' || e[i].type=='radio')");
		includes.Append("e[i].checked=false;");
	    includes.Append("else ");
		includes.Append("e[i].value = ''; ");
		includes.Append("}");
		includes.Append("else if(e[i].name.substr(0,6)=='value_' && e[i].type=='hidden')");
		includes.Append("e[i].value = ''; ");
	    includes.Append("}");
	    includes.Append("ShowHideControls();	");
	    includes.Append("return false;");
        includes.Append("}");

                includes.Append("$(document).ready(function() {");
	        includes.Append("document.forms.editform.value_CateDetailID.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_CateDetailID,'advanced')};");
	        includes.Append("document.forms.editform.value1_CateDetailID.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_CateDetailID,'advanced1')};");
	        includes.Append("document.forms.editform.value_CateDetailID.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_CateDetailID,'advanced')};");
	        includes.Append("document.forms.editform.value1_CateDetailID.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_CateDetailID,'advanced1')};");
	        includes.Append("document.forms.editform.value_Name.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_Name,'advanced')};");
	        includes.Append("document.forms.editform.value1_Name.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_Name,'advanced1')};");
	        includes.Append("document.forms.editform.value_Name.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_Name,'advanced')};");
	        includes.Append("document.forms.editform.value1_Name.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_Name,'advanced1')};");
	        includes.Append("document.forms.editform.value_Description.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_Description,'advanced')};");
	        includes.Append("document.forms.editform.value1_Description.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_Description,'advanced1')};");
	        includes.Append("document.forms.editform.value_Description.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_Description,'advanced')};");
	        includes.Append("document.forms.editform.value1_Description.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_Description,'advanced1')};");
	        includes.Append("document.forms.editform.value_Image.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_Image,'advanced')};");
	        includes.Append("document.forms.editform.value1_Image.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_Image,'advanced1')};");
	        includes.Append("document.forms.editform.value_Image.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_Image,'advanced')};");
	        includes.Append("document.forms.editform.value1_Image.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_Image,'advanced1')};");
	        includes.Append("document.forms.editform.value_Price.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_Price,'advanced')};");
	        includes.Append("document.forms.editform.value1_Price.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_Price,'advanced1')};");
	        includes.Append("document.forms.editform.value_Price.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_Price,'advanced')};");
	        includes.Append("document.forms.editform.value1_Price.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_Price,'advanced1')};");
	        includes.Append("document.forms.editform.value_Quantity.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_Quantity,'advanced')};");
	        includes.Append("document.forms.editform.value1_Quantity.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_Quantity,'advanced1')};");
	        includes.Append("document.forms.editform.value_Quantity.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_Quantity,'advanced')};");
	        includes.Append("document.forms.editform.value1_Quantity.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_Quantity,'advanced1')};");
	        includes.Append("document.forms.editform.value_QuantitySold.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_QuantitySold,'advanced')};");
	        includes.Append("document.forms.editform.value1_QuantitySold.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_QuantitySold,'advanced1')};");
	        includes.Append("document.forms.editform.value_QuantitySold.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_QuantitySold,'advanced')};");
	        includes.Append("document.forms.editform.value1_QuantitySold.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_QuantitySold,'advanced1')};");
        includes.Append("});");
        includes.Append("</script>");
        includes.Append("<div id=\"search_suggest\"></div>");

        return includes.ToString();
    }

    protected void BuildForm()
    {
        string all_checkbox="value=\"and\"";
        string any_checkbox="value=\"or\"";

        if(Asearchtype == "or")
        {
	        any_checkbox +=" checked";
        }
        else
        {
	        all_checkbox +=" checked";
        }
        smarty.Add("any_checkbox",any_checkbox);
        smarty.Add("all_checkbox",all_checkbox);

        IDictionary<string, string> editformats = new Dictionary<string, string>();
        string opt = "";
        bool not = false;
        string value = string.Empty;
        StringBuilder options = new StringBuilder();
        string searchtype = string.Empty;

        // CateDetailID 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["CateDetailID"];
	        not = Asearchnot["CateDetailID"];
	        value = Asearchfor["CateDetailID"];
        }

        Control control_CateDetailID = null;
        Control control1_CateDetailID = null;

        control_CateDetailID = new Control("CateDetailID", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
        
        smarty.Add("CateDetailID_editcontrol", control_CateDetailID.BuildEditControl());
        control1_CateDetailID = new Control("CateDetailID", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                smarty.Add("CateDetailID_editcontrol1", control1_CateDetailID.BuildEditControl());

        IDictionary<string, string> CateDetailID_fieldblock = new Dictionary<string, string>();
	    CateDetailID_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"CateDetailID\">";
	    CateDetailID_fieldblock["end"]=string.Empty;
	    smarty.Add("CateDetailID_fieldblock", CateDetailID_fieldblock);

        string CateDetailID_notbox="name=\"not_CateDetailID\"";
        if(not)
        {
	        CateDetailID_notbox +=" checked";
        }
        smarty.Add("CateDetailID_notbox",CateDetailID_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Contains\" " + ((opt=="Contains")?"selected":"") + ">" + "Contains" + "</option>");
        options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        options.Append("<OPTION VALUE=\"Starts with ...\" " + ((opt=="Starts with ...")?"selected":"") + ">" + "Starts with ..." + "</option>");
        options.Append("<OPTION VALUE=\"More than ...\" " + ((opt=="More than ...")?"selected":"") + ">" + "More than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Less than ...\" " + ((opt=="Less than ...")?"selected":"") + ">" + "Less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or more than ...\" " + ((opt=="Equal or more than ...")?"selected":"") + ">" + "Equal or more than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or less than ...\" " + ((opt=="Equal or less than ...")?"selected":"") + ">" + "Equal or less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Between\" " + ((opt=="Between")?"selected":"") + ">" + "Between" + "</option>");
        options.Append("<OPTION VALUE=\"Empty\" " + ((opt=="Empty")?"selected":"") + ">" + "Empty" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_CateDetailID\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_CateDetailID", searchtype);
        //	edit format
                editformats["CateDetailID"] = "Text field";
        // Name 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["Name"];
	        not = Asearchnot["Name"];
	        value = Asearchfor["Name"];
        }

        Control control_Name = null;
        Control control1_Name = null;

        control_Name = new Control("Name", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
        
        smarty.Add("Name_editcontrol", control_Name.BuildEditControl());
        control1_Name = new Control("Name", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                smarty.Add("Name_editcontrol1", control1_Name.BuildEditControl());

        IDictionary<string, string> Name_fieldblock = new Dictionary<string, string>();
	    Name_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"Name\">";
	    Name_fieldblock["end"]=string.Empty;
	    smarty.Add("Name_fieldblock", Name_fieldblock);

        string Name_notbox="name=\"not_Name\"";
        if(not)
        {
	        Name_notbox +=" checked";
        }
        smarty.Add("Name_notbox",Name_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Contains\" " + ((opt=="Contains")?"selected":"") + ">" + "Contains" + "</option>");
        options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        options.Append("<OPTION VALUE=\"Starts with ...\" " + ((opt=="Starts with ...")?"selected":"") + ">" + "Starts with ..." + "</option>");
        options.Append("<OPTION VALUE=\"More than ...\" " + ((opt=="More than ...")?"selected":"") + ">" + "More than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Less than ...\" " + ((opt=="Less than ...")?"selected":"") + ">" + "Less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or more than ...\" " + ((opt=="Equal or more than ...")?"selected":"") + ">" + "Equal or more than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or less than ...\" " + ((opt=="Equal or less than ...")?"selected":"") + ">" + "Equal or less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Between\" " + ((opt=="Between")?"selected":"") + ">" + "Between" + "</option>");
        options.Append("<OPTION VALUE=\"Empty\" " + ((opt=="Empty")?"selected":"") + ">" + "Empty" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_Name\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_Name", searchtype);
        //	edit format
                editformats["Name"] = "Text field";
        // CateID 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["CateID"];
	        not = Asearchnot["CateID"];
	        value = Asearchfor["CateID"];
        }

        Control control_CateID = null;
        Control control1_CateID = null;

        control_CateID = new Control("CateID", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
                func.PopulateLookupFields(control_CateID.FieldInfo);

        smarty.Add("CateID_editcontrol", control_CateID.BuildEditControl());
        control1_CateID = new Control("CateID", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                func.PopulateLookupFields(control1_CateID.FieldInfo);
        smarty.Add("CateID_editcontrol1", control1_CateID.BuildEditControl());

        IDictionary<string, string> CateID_fieldblock = new Dictionary<string, string>();
	    CateID_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"CateID\">";
	    CateID_fieldblock["end"]=string.Empty;
	    smarty.Add("CateID_fieldblock", CateID_fieldblock);

        string CateID_notbox="name=\"not_CateID\"";
        if(not)
        {
	        CateID_notbox +=" checked";
        }
        smarty.Add("CateID_notbox",CateID_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_CateID\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_CateID", searchtype);
        //	edit format
                editformats["CateID"] = "Lookup wizard";
        // Description 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["Description"];
	        not = Asearchnot["Description"];
	        value = Asearchfor["Description"];
        }

        Control control_Description = null;
        Control control1_Description = null;

        control_Description = new Control("Description", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
        
        smarty.Add("Description_editcontrol", control_Description.BuildEditControl());
        control1_Description = new Control("Description", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                smarty.Add("Description_editcontrol1", control1_Description.BuildEditControl());

        IDictionary<string, string> Description_fieldblock = new Dictionary<string, string>();
	    Description_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"Description\">";
	    Description_fieldblock["end"]=string.Empty;
	    smarty.Add("Description_fieldblock", Description_fieldblock);

        string Description_notbox="name=\"not_Description\"";
        if(not)
        {
	        Description_notbox +=" checked";
        }
        smarty.Add("Description_notbox",Description_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Contains\" " + ((opt=="Contains")?"selected":"") + ">" + "Contains" + "</option>");
        options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        options.Append("<OPTION VALUE=\"Starts with ...\" " + ((opt=="Starts with ...")?"selected":"") + ">" + "Starts with ..." + "</option>");
        options.Append("<OPTION VALUE=\"More than ...\" " + ((opt=="More than ...")?"selected":"") + ">" + "More than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Less than ...\" " + ((opt=="Less than ...")?"selected":"") + ">" + "Less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or more than ...\" " + ((opt=="Equal or more than ...")?"selected":"") + ">" + "Equal or more than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or less than ...\" " + ((opt=="Equal or less than ...")?"selected":"") + ">" + "Equal or less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Between\" " + ((opt=="Between")?"selected":"") + ">" + "Between" + "</option>");
        options.Append("<OPTION VALUE=\"Empty\" " + ((opt=="Empty")?"selected":"") + ">" + "Empty" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_Description\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_Description", searchtype);
        //	edit format
                editformats["Description"] = "Text field";
        // VipLevel 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["VipLevel"];
	        not = Asearchnot["VipLevel"];
	        value = Asearchfor["VipLevel"];
        }

        Control control_VipLevel = null;
        Control control1_VipLevel = null;

        control_VipLevel = new Control("VipLevel", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
        
        smarty.Add("VipLevel_editcontrol", control_VipLevel.BuildEditControl());
        control1_VipLevel = new Control("VipLevel", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                smarty.Add("VipLevel_editcontrol1", control1_VipLevel.BuildEditControl());

        IDictionary<string, string> VipLevel_fieldblock = new Dictionary<string, string>();
	    VipLevel_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"VipLevel\">";
	    VipLevel_fieldblock["end"]=string.Empty;
	    smarty.Add("VipLevel_fieldblock", VipLevel_fieldblock);

        string VipLevel_notbox="name=\"not_VipLevel\"";
        if(not)
        {
	        VipLevel_notbox +=" checked";
        }
        smarty.Add("VipLevel_notbox",VipLevel_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_VipLevel\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_VipLevel", searchtype);
        //	edit format
                editformats["VipLevel"] = "Lookup wizard";
        // Active 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["Active"];
	        not = Asearchnot["Active"];
	        value = Asearchfor["Active"];
        }

        Control control_Active = null;
        Control control1_Active = null;

        control_Active = new Control("Active", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
        
        smarty.Add("Active_editcontrol", control_Active.BuildEditControl());
        control1_Active = new Control("Active", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                smarty.Add("Active_editcontrol1", control1_Active.BuildEditControl());

        IDictionary<string, string> Active_fieldblock = new Dictionary<string, string>();
	    Active_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"Active\">";
	    Active_fieldblock["end"]=string.Empty;
	    smarty.Add("Active_fieldblock", Active_fieldblock);

        string Active_notbox="name=\"not_Active\"";
        if(not)
        {
	        Active_notbox +=" checked";
        }
        smarty.Add("Active_notbox",Active_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_Active\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_Active", searchtype);
        //	edit format
                editformats["Active"] = "Lookup wizard";
        // Image 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["Image"];
	        not = Asearchnot["Image"];
	        value = Asearchfor["Image"];
        }

        Control control_Image = null;
        Control control1_Image = null;

        control_Image = new Control("Image", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
        
        smarty.Add("Image_editcontrol", control_Image.BuildEditControl());
        control1_Image = new Control("Image", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                smarty.Add("Image_editcontrol1", control1_Image.BuildEditControl());

        IDictionary<string, string> Image_fieldblock = new Dictionary<string, string>();
	    Image_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"Image\">";
	    Image_fieldblock["end"]=string.Empty;
	    smarty.Add("Image_fieldblock", Image_fieldblock);

        string Image_notbox="name=\"not_Image\"";
        if(not)
        {
	        Image_notbox +=" checked";
        }
        smarty.Add("Image_notbox",Image_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Contains\" " + ((opt=="Contains")?"selected":"") + ">" + "Contains" + "</option>");
        options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        options.Append("<OPTION VALUE=\"Starts with ...\" " + ((opt=="Starts with ...")?"selected":"") + ">" + "Starts with ..." + "</option>");
        options.Append("<OPTION VALUE=\"More than ...\" " + ((opt=="More than ...")?"selected":"") + ">" + "More than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Less than ...\" " + ((opt=="Less than ...")?"selected":"") + ">" + "Less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or more than ...\" " + ((opt=="Equal or more than ...")?"selected":"") + ">" + "Equal or more than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or less than ...\" " + ((opt=="Equal or less than ...")?"selected":"") + ">" + "Equal or less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Between\" " + ((opt=="Between")?"selected":"") + ">" + "Between" + "</option>");
        options.Append("<OPTION VALUE=\"Empty\" " + ((opt=="Empty")?"selected":"") + ">" + "Empty" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_Image\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_Image", searchtype);
        //	edit format
                editformats["Image"] = "Text field";
        // Price 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["Price"];
	        not = Asearchnot["Price"];
	        value = Asearchfor["Price"];
        }

        Control control_Price = null;
        Control control1_Price = null;

        control_Price = new Control("Price", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
        
        smarty.Add("Price_editcontrol", control_Price.BuildEditControl());
        control1_Price = new Control("Price", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                smarty.Add("Price_editcontrol1", control1_Price.BuildEditControl());

        IDictionary<string, string> Price_fieldblock = new Dictionary<string, string>();
	    Price_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"Price\">";
	    Price_fieldblock["end"]=string.Empty;
	    smarty.Add("Price_fieldblock", Price_fieldblock);

        string Price_notbox="name=\"not_Price\"";
        if(not)
        {
	        Price_notbox +=" checked";
        }
        smarty.Add("Price_notbox",Price_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Contains\" " + ((opt=="Contains")?"selected":"") + ">" + "Contains" + "</option>");
        options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        options.Append("<OPTION VALUE=\"Starts with ...\" " + ((opt=="Starts with ...")?"selected":"") + ">" + "Starts with ..." + "</option>");
        options.Append("<OPTION VALUE=\"More than ...\" " + ((opt=="More than ...")?"selected":"") + ">" + "More than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Less than ...\" " + ((opt=="Less than ...")?"selected":"") + ">" + "Less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or more than ...\" " + ((opt=="Equal or more than ...")?"selected":"") + ">" + "Equal or more than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or less than ...\" " + ((opt=="Equal or less than ...")?"selected":"") + ">" + "Equal or less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Between\" " + ((opt=="Between")?"selected":"") + ">" + "Between" + "</option>");
        options.Append("<OPTION VALUE=\"Empty\" " + ((opt=="Empty")?"selected":"") + ">" + "Empty" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_Price\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_Price", searchtype);
        //	edit format
                editformats["Price"] = "Text field";
        // Status 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["Status"];
	        not = Asearchnot["Status"];
	        value = Asearchfor["Status"];
        }

        Control control_Status = null;
        Control control1_Status = null;

        control_Status = new Control("Status", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
        
        smarty.Add("Status_editcontrol", control_Status.BuildEditControl());
        control1_Status = new Control("Status", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                smarty.Add("Status_editcontrol1", control1_Status.BuildEditControl());

        IDictionary<string, string> Status_fieldblock = new Dictionary<string, string>();
	    Status_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"Status\">";
	    Status_fieldblock["end"]=string.Empty;
	    smarty.Add("Status_fieldblock", Status_fieldblock);

        string Status_notbox="name=\"not_Status\"";
        if(not)
        {
	        Status_notbox +=" checked";
        }
        smarty.Add("Status_notbox",Status_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_Status\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_Status", searchtype);
        //	edit format
                editformats["Status"] = "Lookup wizard";
        // Quantity 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["Quantity"];
	        not = Asearchnot["Quantity"];
	        value = Asearchfor["Quantity"];
        }

        Control control_Quantity = null;
        Control control1_Quantity = null;

        control_Quantity = new Control("Quantity", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
        
        smarty.Add("Quantity_editcontrol", control_Quantity.BuildEditControl());
        control1_Quantity = new Control("Quantity", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                smarty.Add("Quantity_editcontrol1", control1_Quantity.BuildEditControl());

        IDictionary<string, string> Quantity_fieldblock = new Dictionary<string, string>();
	    Quantity_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"Quantity\">";
	    Quantity_fieldblock["end"]=string.Empty;
	    smarty.Add("Quantity_fieldblock", Quantity_fieldblock);

        string Quantity_notbox="name=\"not_Quantity\"";
        if(not)
        {
	        Quantity_notbox +=" checked";
        }
        smarty.Add("Quantity_notbox",Quantity_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Contains\" " + ((opt=="Contains")?"selected":"") + ">" + "Contains" + "</option>");
        options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        options.Append("<OPTION VALUE=\"Starts with ...\" " + ((opt=="Starts with ...")?"selected":"") + ">" + "Starts with ..." + "</option>");
        options.Append("<OPTION VALUE=\"More than ...\" " + ((opt=="More than ...")?"selected":"") + ">" + "More than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Less than ...\" " + ((opt=="Less than ...")?"selected":"") + ">" + "Less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or more than ...\" " + ((opt=="Equal or more than ...")?"selected":"") + ">" + "Equal or more than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or less than ...\" " + ((opt=="Equal or less than ...")?"selected":"") + ">" + "Equal or less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Between\" " + ((opt=="Between")?"selected":"") + ">" + "Between" + "</option>");
        options.Append("<OPTION VALUE=\"Empty\" " + ((opt=="Empty")?"selected":"") + ">" + "Empty" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_Quantity\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_Quantity", searchtype);
        //	edit format
                editformats["Quantity"] = "Text field";
        // QuantitySold 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["QuantitySold"];
	        not = Asearchnot["QuantitySold"];
	        value = Asearchfor["QuantitySold"];
        }

        Control control_QuantitySold = null;
        Control control1_QuantitySold = null;

        control_QuantitySold = new Control("QuantitySold", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
        
        smarty.Add("QuantitySold_editcontrol", control_QuantitySold.BuildEditControl());
        control1_QuantitySold = new Control("QuantitySold", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                smarty.Add("QuantitySold_editcontrol1", control1_QuantitySold.BuildEditControl());

        IDictionary<string, string> QuantitySold_fieldblock = new Dictionary<string, string>();
	    QuantitySold_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"QuantitySold\">";
	    QuantitySold_fieldblock["end"]=string.Empty;
	    smarty.Add("QuantitySold_fieldblock", QuantitySold_fieldblock);

        string QuantitySold_notbox="name=\"not_QuantitySold\"";
        if(not)
        {
	        QuantitySold_notbox +=" checked";
        }
        smarty.Add("QuantitySold_notbox",QuantitySold_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Contains\" " + ((opt=="Contains")?"selected":"") + ">" + "Contains" + "</option>");
        options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        options.Append("<OPTION VALUE=\"Starts with ...\" " + ((opt=="Starts with ...")?"selected":"") + ">" + "Starts with ..." + "</option>");
        options.Append("<OPTION VALUE=\"More than ...\" " + ((opt=="More than ...")?"selected":"") + ">" + "More than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Less than ...\" " + ((opt=="Less than ...")?"selected":"") + ">" + "Less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or more than ...\" " + ((opt=="Equal or more than ...")?"selected":"") + ">" + "Equal or more than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or less than ...\" " + ((opt=="Equal or less than ...")?"selected":"") + ">" + "Equal or less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Between\" " + ((opt=="Between")?"selected":"") + ">" + "Between" + "</option>");
        options.Append("<OPTION VALUE=\"Empty\" " + ((opt=="Empty")?"selected":"") + ">" + "Empty" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_QuantitySold\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_QuantitySold", searchtype);
        //	edit format
                editformats["QuantitySold"] = "Text field";
        // CreatedDate 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["CreatedDate"];
	        not = Asearchnot["CreatedDate"];
	        value = Asearchfor["CreatedDate"];
        }

        Control control_CreatedDate = null;
        Control control1_CreatedDate = null;

        control_CreatedDate = new Control("CreatedDate", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
        
        smarty.Add("CreatedDate_editcontrol", control_CreatedDate.BuildEditControl());
        control1_CreatedDate = new Control("CreatedDate", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                smarty.Add("CreatedDate_editcontrol1", control1_CreatedDate.BuildEditControl());

        IDictionary<string, string> CreatedDate_fieldblock = new Dictionary<string, string>();
	    CreatedDate_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"CreatedDate\">";
	    CreatedDate_fieldblock["end"]=string.Empty;
	    smarty.Add("CreatedDate_fieldblock", CreatedDate_fieldblock);

        string CreatedDate_notbox="name=\"not_CreatedDate\"";
        if(not)
        {
	        CreatedDate_notbox +=" checked";
        }
        smarty.Add("CreatedDate_notbox",CreatedDate_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        options.Append("<OPTION VALUE=\"More than ...\" " + ((opt=="More than ...")?"selected":"") + ">" + "More than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Less than ...\" " + ((opt=="Less than ...")?"selected":"") + ">" + "Less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or more than ...\" " + ((opt=="Equal or more than ...")?"selected":"") + ">" + "Equal or more than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or less than ...\" " + ((opt=="Equal or less than ...")?"selected":"") + ">" + "Equal or less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Between\" " + ((opt=="Between")?"selected":"") + ">" + "Between" + "</option>");
        options.Append("<OPTION VALUE=\"Empty\" " + ((opt=="Empty")?"selected":"") + ">" + "Empty" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_CreatedDate\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_CreatedDate", searchtype);
        //	edit format
                editformats["CreatedDate"] = "Date";
        // UpdatedDate 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["UpdatedDate"];
	        not = Asearchnot["UpdatedDate"];
	        value = Asearchfor["UpdatedDate"];
        }

        Control control_UpdatedDate = null;
        Control control1_UpdatedDate = null;

        control_UpdatedDate = new Control("UpdatedDate", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
        
        smarty.Add("UpdatedDate_editcontrol", control_UpdatedDate.BuildEditControl());
        control1_UpdatedDate = new Control("UpdatedDate", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                smarty.Add("UpdatedDate_editcontrol1", control1_UpdatedDate.BuildEditControl());

        IDictionary<string, string> UpdatedDate_fieldblock = new Dictionary<string, string>();
	    UpdatedDate_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"UpdatedDate\">";
	    UpdatedDate_fieldblock["end"]=string.Empty;
	    smarty.Add("UpdatedDate_fieldblock", UpdatedDate_fieldblock);

        string UpdatedDate_notbox="name=\"not_UpdatedDate\"";
        if(not)
        {
	        UpdatedDate_notbox +=" checked";
        }
        smarty.Add("UpdatedDate_notbox",UpdatedDate_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        options.Append("<OPTION VALUE=\"More than ...\" " + ((opt=="More than ...")?"selected":"") + ">" + "More than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Less than ...\" " + ((opt=="Less than ...")?"selected":"") + ">" + "Less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or more than ...\" " + ((opt=="Equal or more than ...")?"selected":"") + ">" + "Equal or more than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Equal or less than ...\" " + ((opt=="Equal or less than ...")?"selected":"") + ">" + "Equal or less than ..." + "</option>");
        options.Append("<OPTION VALUE=\"Between\" " + ((opt=="Between")?"selected":"") + ">" + "Between" + "</option>");
        options.Append("<OPTION VALUE=\"Empty\" " + ((opt=="Empty")?"selected":"") + ">" + "Empty" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_UpdatedDate\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_UpdatedDate", searchtype);
        //	edit format
                editformats["UpdatedDate"] = "Date";
        // Hot 
        opt = "";
        not = false;
        value = string.Empty;
        searchtype = string.Empty;
        if(Search == 2)
        {
	        opt = Asearchopt["Hot"];
	        not = Asearchnot["Hot"];
	        value = Asearchfor["Hot"];
        }

        Control control_Hot = null;
        Control control1_Hot = null;

        control_Hot = new Control("Hot", value, false, smarty, this.Request, builder, MODE.MODE_SEARCH);
        
        smarty.Add("Hot_editcontrol", control_Hot.BuildEditControl());
        control1_Hot = new Control("Hot", value, true, smarty, this.Request, builder, MODE.MODE_SEARCH);
                smarty.Add("Hot_editcontrol1", control1_Hot.BuildEditControl());

        IDictionary<string, string> Hot_fieldblock = new Dictionary<string, string>();
	    Hot_fieldblock["begin"] = "<input type=\"Hidden\" name=\"asearchfield[]\" value=\"Hot\">";
	    Hot_fieldblock["end"]=string.Empty;
	    smarty.Add("Hot_fieldblock", Hot_fieldblock);

        string Hot_notbox="name=\"not_Hot\"";
        if(not)
        {
	        Hot_notbox +=" checked";
        }
        smarty.Add("Hot_notbox",Hot_notbox);

        //	write search options
        options = options.Remove(0, options.Length);
                options.Append("<OPTION VALUE=\"Equals\" " + ((opt=="Equals")?"selected":"") + ">" + "Equals" + "</option>");
        searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_Hot\" SIZE=1 onChange=\"return ShowHideControls();\">";
        searchtype += options.ToString();
        searchtype += "</SELECT>";
        smarty.Add("searchtype_Hot", searchtype);
        //	edit format
                editformats["Hot"] = "Checkbox";
    }

    protected void BuildBody()
    {
        string linkdata="";

        linkdata += "<script type=\"text/javascript\">\r\n";
        object value = null;
        if(Asearchfor.ContainsKey(""))
        {
            value = Asearchfor[""] ;
        }
        object fvalue = null;
        if(Asearchfor.ContainsKey("ArtID"))
        {
            fvalue = Asearchfor["ArtID"];
        }

        if (useAJAX) 
        {
            Smarty.Table tableInfo = null;
            Smarty.Field fieldInfo = null;
            List<Smarty.LookupField> lookups = null;
            string txt = ""; 

        }
        else
        {
        }
        linkdata += "</script>\r\n";


        IDictionary<string, object> body = new Dictionary<string, object>();
        body["begin"] = GetIncludes();
        body["end"] = linkdata + "<script>ShowHideControls()</script>";
        smarty.Add("body", body);

        IDictionary<string, object> contents_block = new Dictionary<string, object>();
        contents_block["begin"]="<form method=\"POST\"";
                contents_block["begin"] += "action=\"categorydetail_list.aspx\"" ;
        contents_block["begin"] += "name=\"editform\"><input type=\"hidden\" id=\"a\" name=\"a\" value=\"advsearch\">";
        contents_block["end"] ="</form>";
        smarty.Add("contents_block",contents_block);

        smarty.Add("searchbutton_attrs","name=\"SearchButton\" onclick=\"javascript:document.forms.editform.submit();\"");
        smarty.Add("resetbutton_attrs","onclick=\"return ResetControls();\"");
        smarty.Add("backbutton_attrs","onclick=\"javascript: document.forms.editform.a.value='return'; document.forms.editform.submit();\"");
        smarty.Add("conditions_block",true);
        smarty.Add("search_button",true);
        smarty.Add("reset_button",true);
        smarty.Add("back_button",true);
    }

        private bool CheckSecurity()
    {
        if(string.IsNullOrEmpty(UserName))
        { 
            MyUrl = this.Request.AppRelativeCurrentExecutionFilePath;
            this.Server.Transfer("~/admin/login.aspx?message=expired");
	        return false;
        }
                if(!BaseCheckSecurity(OwnerID, "Search"))
        {
                }
        return true;
    }

    private string Asearchtype
    {
        get
        {
            return (string)SessionPropertyGet("type", string.Empty);
        }
        set
        {
            SessionPropertySet("type", value);
        }
    }
    
    private int Search
    {
        get
        {
            return (int)SessionPropertyGet(strTableName + "_search", -1);
        }
        set
        {
            SessionPropertySet(strTableName + "_search", value);
        }
    }

    private IDictionary<string, string> Asearchopt
    {
        get
        {
            return (IDictionary<string, string>)SessionPropertyGet(strTableName + "_asearchopt", new Dictionary<string, string>());
        }
        set
        {
            SessionPropertySet(strTableName + "_asearchopt", value);
        }
    }

    private IDictionary<string, bool> Asearchnot
    {
        get
        {
            return (IDictionary<string, bool>)SessionPropertyGet(strTableName + "_asearchnot", new Dictionary<string, bool>());
        }
        set
        {
            SessionPropertySet(strTableName + "_asearchnot", value);
        }
    }

    private IDictionary<string, string> Asearchfor
    {
        get
        {
            return (IDictionary<string, string>)SessionPropertyGet(strTableName + "_asearchfor", new Dictionary<string, string>());
        }
        set
        {
            SessionPropertySet(strTableName + "_asearchfor", value);
        }
    }

    private string Mastertable
    {
        get
        {
            return (string)SessionPropertyGet(strTableName + "_mastertable", string.Empty);
        }
        set
        {
            SessionPropertySet(strTableName + "_mastertable", value);
        }
    }
}
